package com.nifostasky.comic.enums;

import lombok.Getter;

import java.util.Objects;

/**
 * 所属区域状态枚举
 */
@Getter
public enum SysOrgStatusEnum {
    STATUS_ONE(1,"启用"),
    STATUS_TWO(2,"禁用"),
    ;
    private Integer code;
    private String name;

    SysOrgStatusEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public static SysOrgStatusEnum parse(String code) {
        return getByCode(code);
    }

    public static SysOrgStatusEnum getByCode(String code) {
        return getByCode(code, true);
    }

    public static SysOrgStatusEnum getByCode(String code, boolean throwIf) {
        Objects.requireNonNull(code, "TaskType code must not be null.");
        for (SysOrgStatusEnum item : values()) {
            if (item.code.equals(code)) {
                return item;
            }
        }
        if (throwIf) {
            return null;
        } else {
            return null;
        }
    }

    public static String getNameByCode(Integer code) {
        Objects.requireNonNull(code, "code must not be null.");
        for (SysOrgStatusEnum item : values()) {
            if (item.code.equals(code)) {
                return item.name;
            }
        }
        return "";
    }
}
